package com.lin.demo.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author zimingl
 * @Date 2023/4/8 0:38
 * @Description: redission 配置
 */
@ConditionalOnClass(Redisson.class)
@EnableConfigurationProperties({RedissionProperties.class})
@Configuration
public class RedissonAutoConfiguration {
    @Bean
    RedissonClient redissonClient(RedissionProperties properties){
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + properties.getHost() + ":" + properties.getPort());
        return Redisson.create(config);
    }
}
